package cn.net.dpi.lock.support;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

public interface Lock {

    default String acquire(@NotBlank String lockId) {

        return acquire(lockId, 10);
    }

    default String acquire(@NotBlank String lockId, Integer expire) {

        return acquire(lockId, expire, 0);
    }

    String acquire(@NotBlank String lockId, Integer expire, @NotNull @Min(0) Integer timeout);

    boolean release(@NotBlank String lockId, @NotBlank String lock);

}
